package org.mydba.info;

/**
 * Stores an Oracle session event.
 *
 * @since 1.0
 */
public class OracleEvent {
    private long id;
    private long totalWaits;
    private long totalTimeouts;
    private long maxWait;
    private long timeWaitedMicro;

    public OracleEvent(final long id, final long totalWaits, final long totalTimeouts, final long maxWait, final long timeWaitedMicro) {
        this.id = id;
        this.totalWaits = totalWaits;
        this.totalTimeouts = totalTimeouts;
        this.maxWait = maxWait;
        this.timeWaitedMicro = timeWaitedMicro;
    }

    public long getId() {
        return id;
    }

    public long getTotalWaits() {
        return totalWaits;
    }

    public long getTotalTimeouts() {
        return totalTimeouts;
    }

    public long getMaxWait() {
        return maxWait;
    }

    public long getTimeWaitedMicro() {
        return timeWaitedMicro;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }

        OracleEvent that = (OracleEvent) o;

        if (id != that.id) {
            return false;
        }
        if (maxWait != that.maxWait) {
            return false;
        }
        if (timeWaitedMicro != that.timeWaitedMicro) {
            return false;
        }
        if (totalTimeouts != that.totalTimeouts) {
            return false;
        }
        if (totalWaits != that.totalWaits) {
            return false;
        }

        return true;
    }

    @Override
    public int hashCode() {
        int result = (int) (id ^ (id >>> 32));
        result = 31 * result + (int) (totalWaits ^ (totalWaits >>> 32));
        result = 31 * result + (int) (totalTimeouts ^ (totalTimeouts >>> 32));
        result = 31 * result + (int) (maxWait ^ (maxWait >>> 32));
        result = 31 * result + (int) (timeWaitedMicro ^ (timeWaitedMicro >>> 32));
        return result;
    }
}
